Skip to content

Conversation

cowboyd
Copy link
Member

@cowboyd cowboyd commented Jan 27, 2023

Motivation

In order to gracefully compose data structures, you need a way to insert an entire set of mappings into another at a single place. This is equivalent to the javascript ... operator.

YAML allows support for this with the language independent type "merge-key" feature.

Approach

This implements the spec here https://yaml.org/type/merge.html

Thus evaluating this example:

composed:
  <<:
    one: 1
    two: 2
  <<:
    three: 3
    four: 4
  <<:
    -
      five: 5
    -
      six: 6

is:

composed:
  one: 1
  two: 2
  three: 3
  four: 4
  five: 5
  six: 6

Learning

Although ubiquitous, this syntax is officially deprecated and will be replaced by something else in YAML 1.3 but nobody is for sure what that will be.

@cowboyd cowboyd requested a review from a team January 27, 2023 16:21
In order to gracefully compose data structures, you need a way to
insert an entire set of mappings into another at a single
place. This is equivalent to the javascript `...` operator.

YAML allows support for this with the language
independent type "merge-key"  feature.

This implements the spec here https://yaml.org/type/merge.html

Thus evaluating this example:

```yaml
composed:
  <<:
    one: 1
    two: 2
  <<:
    three: 3
    four: 4
  <<:
    -
      five: 5
    -
      six: 6
```

is:

```yaml
composed:
  one: 1
  two: 2
  three: 3
  four: 4
  five: 5
  six: 6
```

Although ubiquitous, this syntax is officially deprecated and will
be replaced by something else in YAML 1.3 but nobody is for sure what
that will be.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant